package restful_apis.document_reranking;

import org.springframework.stereotype.Component;
import restful_apis.common.MediaTypes;
import result_reranking.entity_rank.DocumentRanking;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;

/**
 * Created by julianzliu on 5/4/2017.
 */


@Path("/ranking")
@Produces(MediaTypes.JSON_UTF8)
@Component
public class DocumentRankingRest {


    private DocumentRanking documentRanking;

    public DocumentRankingRest(){
        this.documentRanking = new DocumentRanking();
    }


    @GET
    @Path("/_query")
    @Produces(MediaTypes.JSON_UTF8)
    public String  searchRankedDocument(
            @QueryParam("query") String query
    ){
        String result = this.documentRanking.rankResult( query, false );

        return result;
    }

    @GET
    @Path("/_explain")
    @Produces(MediaTypes.JSON_UTF8)
    public String  explainRankedDocument(
            @QueryParam("query") String query
    ){
        String result = this.documentRanking.rankResult( query, true );

        return result;
    }


    @GET
    @Path("/_simple")
    @Produces(MediaTypes.JSON_UTF8)
    public String  searchSimpleDocument(
            @QueryParam("query") String query
    ){
        String result = this.documentRanking.simpleQuery( query );

        return result;
    }

}
